package com.ruoyi.web.controller.goWhere;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GoWhere;
import com.ruoyi.system.service.IGoWhereService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 去哪拍Controller
 * 
 * @author Eugene
 * @date 2023-04-19
 */
@Api(tags = "去哪拍")
@RestController
@RequestMapping("/GoWhere/where")
public class GoWhereController extends BaseController
{
    @Autowired
    private IGoWhereService goWhereService;

    /**
     * 查询去哪拍列表
     */
    @ApiOperation("查询去哪拍列表")
    @PreAuthorize("@ss.hasPermi('GoWhere:where:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoWhere goWhere)
    {
        startPage();
        List<GoWhere> list = goWhereService.selectGoWhereList(goWhere);
        return getDataTable(list);
    }

    /**
     * 导出去哪拍列表
     */
    @PreAuthorize("@ss.hasPermi('GoWhere:where:export')")
    @Log(title = "去哪拍", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoWhere goWhere)
    {
        List<GoWhere> list = goWhereService.selectGoWhereList(goWhere);
        ExcelUtil<GoWhere> util = new ExcelUtil<GoWhere>(GoWhere.class);
        util.exportExcel(response, list, "去哪拍数据");
    }

    /**
     * 获取去哪拍详细信息
     */
    @ApiOperation("获取去哪拍详细信息")
    @PreAuthorize("@ss.hasPermi('GoWhere:where:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(goWhereService.selectGoWhereById(id));
    }

    /**
     * 新增去哪拍
     */
    @ApiOperation("新增去哪拍")
    @PreAuthorize("@ss.hasPermi('GoWhere:where:add')")
    @Log(title = "去哪拍", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoWhere goWhere)
    {
        return toAjax(goWhereService.insertGoWhere(goWhere));
    }

    /**
     * 修改去哪拍
     */
    @ApiOperation("修改去哪拍")
    @PreAuthorize("@ss.hasPermi('GoWhere:where:edit')")
    @Log(title = "去哪拍", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoWhere goWhere)
    {
        return toAjax(goWhereService.updateGoWhere(goWhere));
    }

    /**
     * 删除去哪拍
     */
    @ApiOperation("删除去哪拍")
    @PreAuthorize("@ss.hasPermi('GoWhere:where:remove')")
    @Log(title = "去哪拍", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(goWhereService.deleteGoWhereByIds(ids));
    }
}
